import axios from '@/axios'

// 添加频道
export function addChatChannel(data) {
  return axios({
    url: '/chat-im/chatChannel',
    method: 'post',
    data,
  })
}

// 修改频道
export function updateChatChannel(data) {
  return axios({
    url: '/chat-im/chatChannel',
    method: 'put',
    data,
  })
}

// 查询频道列表
export function getChatChannelList(params) {
  return axios({
    url: '/chat-im/chatChannel/listUserChannel',
    method: 'get',
    params,
  })
}

// 删除频道
export function deleteChatChannelList(channelId) {
  return axios({
    url: '/chat-im/chatChannel/' + channelId,
    method: 'delete',
  })
}

// 查询频道成员消息
export function getChannelMsgCount(userId) {
  return axios({
    url: '/chat-im/chatChannel/user/' + userId + '/members',
    method: 'get',
  })
}

// 查询频道成员
export function getChannelMembers(channelId) {
  return axios({
    url: '/chat-im/chatChannel/' + channelId + '/members',
    method: 'get',
  })
}

// 添加频道成员
export function addChannelMembers(channelId, data) {
  return axios({
    url: '/chat-im/chatChannel/' + channelId + '/members',
    method: 'post',
    data,
  })
}

// 删除频道成员
export function deleteChannelMember(channelId, data) {
  return axios({
    url: '/chat-im/chatChannel/' + channelId + '/members',
    method: 'delete',
    data,
  })
}

// 退出频道
export function leaveChannelMember(channelId) {
  return axios({
    url: '/chat-im/chatChannel/' + channelId + '/members/leave',
    method: 'delete',
  })
}
